package com.neusoft.elm.controller;
import java.util.List;
import java.math.BigDecimal;
import javax.servlet.http.HttpServletRequest;
import com.neusoft.elm.po.Business;
import com.neusoft.elm.service.BusinessService;
import com.neusoft.elm.service.impl.BusinessServiceImpl;
public class BusinessController {
 public Object listBusinessByOrderTypeId(HttpServletRequest request) throws Exception{
 Integer orderTypeId = Integer.valueOf(request.getParameter("orderTypeId"));
 BusinessService service = new BusinessServiceImpl();
 List<Business> list= service.listBusinessByOrderTypeId(orderTypeId);
 return list;
 }
 
 public Object getBusinessById(HttpServletRequest request) throws Exception{
 Integer businessId = Integer.valueOf(request.getParameter("businessId"));
 BusinessService service = new BusinessServiceImpl();
 Business business = service.getBusinessById(businessId);
 return business;
 }

 public Object getBusinessByUsernamePassword(HttpServletRequest request) throws Exception{
 String username = request.getParameter("businessUsername");
 String password = request.getParameter("businessPassword");
 BusinessService service = new BusinessServiceImpl();
 Business business = service.getBusinessByUsernamePassword(username, password);
 return business;
 }

 public Object saveBusiness(HttpServletRequest request) throws Exception{
 String businessName = request.getParameter("businessName");
 String businessAddress = request.getParameter("businessAddress");
 String businessExplain = request.getParameter("businessExplain");
 String businessImg = request.getParameter("businessImg");
 Integer orderTypeId = Integer.valueOf(request.getParameter("orderTypeId"));
 BigDecimal starPrice = new BigDecimal(request.getParameter("starPrice"));
 BigDecimal deliveryPrice = new BigDecimal(request.getParameter("deliveryPrice"));
 String remarks = request.getParameter("remarks");
 String businessUsername = request.getParameter("businessUsername");
 String businessPassword = request.getParameter("businessPassword");
 
 Business business = new Business();
 business.setBusinessName(businessName);
 business.setBusinessAddress(businessAddress);
 business.setBusinessExplain(businessExplain);
 business.setBusinessImg(businessImg);
 business.setOrderTypeId(orderTypeId);
 business.setStarPrice(starPrice);
 business.setDeliveryPrice(deliveryPrice);
 business.setRemarks(remarks);
 business.setBusinessUsername(businessUsername);
 business.setBusinessPassword(businessPassword);
 
 BusinessService service = new BusinessServiceImpl();
 int result = service.saveBusiness(business);
 return result;
 }
}
